package sharewithus.business.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.util.WebUtils;

import sharewithus.business.dto.Status;
import sharewithus.business.service.IRelationShipService;

import framelib.common.FrameCommon;
import framelib.common.SessionData;
import framelib.controller.AbsController;

/** 
 * @ClassName: RelationShipController 
 * @Description: 
 * @author chenyun
 * @date 2012-5-15 上午10:39:16 
 */
@Controller
public class RelationShipController extends AbsController {
	
	@SuppressWarnings("unchecked")
	@Autowired
	@Qualifier("relationService")
	private IRelationShipService service;
	
	@RequestMapping(value="/rs/addAttention.htm")
	@ResponseBody
	public Status addAttention(String follower, HttpServletRequest request) {
		Status status = new Status();
		
		try {
			SessionData session = (SessionData)WebUtils.getSessionAttribute(request, FrameCommon.PNN_SESSION);
			
			service.addAttention(String.valueOf(session.getId()), follower);
		} catch (Exception e) {
			status.setSuccess(false);
			status.setMsg("");
		}
		
		return status;
	}
	
	@RequestMapping(value="/rs/cancelAttention.htm")
	@ResponseBody
	public Status cancelAttention(String follower, HttpServletRequest request) {
		Status status = new Status();
		
		try {
			SessionData session = (SessionData)WebUtils.getSessionAttribute(request, FrameCommon.PNN_SESSION);
			
			service.cancelAttention(String.valueOf(session.getId()), follower);
		} catch (Exception e) {
			status.setSuccess(false);
			status.setMsg("");
		}
		
		return status;
	}
	
	@RequestMapping(value="/rs/getFansByPage.htm")
	@ResponseBody
	public List<String> getFansByPage(long start, long limit) {
		List<String> fans = new ArrayList<String>();
		
		
		return fans;
	}
	
	@RequestMapping(value="/rs/getFansByPage.htm")
	@ResponseBody
	public List<String> getFollwersByPage(long start, long limit) {
		List<String> fans = new ArrayList<String>();
		
		
		return fans;
	}
}

